package com.sjz.bookmark.setting;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.application.ApplicationManager;

import java.util.Objects;

import static com.sjz.bookmark.setting.Constants.*;

/**
 * 应用全局设置
 *
 * @author shijinze
 */
public final class GlobalSettings extends BaseSetting {
    public GlobalSettings() {
        super(PropertiesComponent.getInstance());
    }

    public static GlobalSettings getInstance() {
        return ApplicationManager.getApplication().getService(GlobalSettings.class);
    }

    public String getMysqlHost() {
        return Objects.toString(properties.getValue(BOOKMARK_MYSQL_HOST), "127.0.0.1");
    }

    public String getMysqlPort() {
        return Objects.toString(properties.getValue(BOOKMARK_MYSQL_PORT), "3306");
    }

    public String getMysqlUser() {
        return Objects.toString(properties.getValue(BOOKMARK_MYSQL_USER), "root");
    }

    public String getMysqlPassword() {
        return Objects.toString(properties.getValue(BOOKMARK_MYSQL_PASSWORD), "12345678");
    }


    public String getMysqlDb() {
        return Objects.toString(properties.getValue(BOOKMARK_MYSQL_Db), "bookmarks");
    }

    // 是否使用mysql,true使用本地  false使用mysql
    public String getUseMysqlCheckBox() {
        return Objects.toString(properties.getValue(BOOKMARK_USEMYSQL_CHECKBOX), "false");
    }

    public String getShowLogCheckBox() {
        return Objects.toString(properties.getValue(BOOKMARK_SHOWLOG_CHECKBOX), "false");
    }

    public void setShowLogCheckBox(String showLogCheckBox) {
        properties.setValue(BOOKMARK_SHOWLOG_CHECKBOX, showLogCheckBox);
    }


}
